<?php

$this->useClass("Handler_Comments");
class Action_Community_DeleteComment extends Handler_Comments
{

	public function process ()
	{
		$aa = $this->module->aa;
		$this->ctx->db->begin();

		$aa->getAvailableOperations();
		$data = $aa->getInfo();

		$comment = $this->m_comment->getOneCommentAsObject( $this->params['id_comment'] );

		$aa->setItemOid( $comment->data['item_oid'] );

		$aa->checkDeletions( array($this, "shutdown") );

		$status = $this->deleteComment( $comment->id );

		// успешно завершение
		$view = $this->rh->views->findByName('deletecomment_success');
		$view->data = $aa->template_data;

		if ($status != COMMENT_OK) {
			$view->data['message'] = "Какая то ошибка, вероятно не найден комментарий в БД.";
		} else {
			$view->data['item_oid'] = $comment->data['item_oid'];
		}

		if (!$this->ctx->db->isErrorInTransaction()) {
			$this->rh->response->setContent($view);
		} else {
			echo "Ошибка при завершении транзакции.";
		}

		$this->ctx->db->end();
	} // end of function process

}
